package com.chukun.inventory.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.JedisCluster;

@Component
public class RedisClusterMapper {

    @Autowired
    private JedisCluster jedisCluster;

    /**
     * set cache
     * @param key
     * @param value
     */
    public void set(String key, String value){
        jedisCluster.set(key, value);
    }

    /**
     * 获取key
     * @param key
     * @return
     */
    public Object get(String key) {
        return jedisCluster.get(key);
    }

    /**
     * 删除对应的key
     * @param key
     */
    public void delete(String key) {
        jedisCluster.del(key);
    }

    /**
     * 判断是否有此key
     * @param key
     * @return
     */
    public boolean existKey(String key){
        return jedisCluster.exists(key);
    }
}
